package nl.cwi.arne.ui;

import nl.cwi.arne.mcrl2.util.MCRL2Options;
import nl.cwi.arne.mcrl2.util.MCRL2Options.Equivalence;

import org.eclipse.jface.preference.IPreferenceStore;

/**
 * Static methods for accessing preferences.
 * @author Christian Krause
 */
public class ArnePreferences {
	
	public static final String AUTO_SAVE = "autoSave";
	public static final String REMOVE_INITIAL_STATES = "removeInitialState";
	public static final String WITH_ZERO_CHANGES = "withZeroChanges";
	public static final String START_FROM_ZERO_CHANGE = "startFromZeroChange";
	public static final String DELTA_LABELS = "deltaLabels";
	public static final String VERBOSE_LABELS = "verboseLabels";

	// Preference store:
	private static IPreferenceStore store;
	
	public static MCRL2Options getMCRL2Options() {
		MCRL2Options options = new MCRL2Options();
		options.setEquivalence(Equivalence.valueOf(getStore().getString(MCRL2Options.EQUIVALENCE)));
		options.setLpssumelm(true);
		options.setLtsconvert(isMinimizeLTS());
		return options;
	}
	
	public static void setMCRL2Options(MCRL2Options options) {
		getStore().setValue(MCRL2Options.EQUIVALENCE, options.getEquivalence().name());
	}
	
	public static boolean isAutoSave() {
		return getStore().getBoolean(AUTO_SAVE);
	}

	public static void setAutoSave(boolean autoSave) {
		getStore().setValue(AUTO_SAVE, autoSave);
	}

	public static boolean isRemoveInitialStates() {
		return getStore().getBoolean(REMOVE_INITIAL_STATES);
	}

	public static void setRemoveInitialStates(boolean remove) {
		getStore().setValue(REMOVE_INITIAL_STATES, remove);
	}

	public static boolean isStartFromZeroChange() {
		return getStore().getBoolean(START_FROM_ZERO_CHANGE);
	}

	public static void setStartFromZeroChange(boolean fromZero) {
		getStore().setValue(START_FROM_ZERO_CHANGE, fromZero);
	}

	public static boolean isWithZeroChanges() {
		return getStore().getBoolean(WITH_ZERO_CHANGES);
	}

	public static void setWithZeroChanges(boolean withZeroChanges) {
		getStore().setValue(WITH_ZERO_CHANGES, withZeroChanges);
	}

	public static boolean isMinimizeLTS() {
		return getStore().getBoolean(MCRL2Options.LTSCONVERT);
	}

	public static void setMinimizeLTS(boolean minimize) {
		getStore().setValue(MCRL2Options.LTSCONVERT, minimize);
	}

	public static boolean isDeltaLabels() {
		return getStore().getBoolean(DELTA_LABELS);
	}

	public static void setDeltaLabels(boolean deltaLabels) {
		getStore().setValue(DELTA_LABELS, deltaLabels);
	}

	public static boolean isVerboseLabels() {
		return getStore().getBoolean(VERBOSE_LABELS);
	}

	public static void setVerboseLabels(boolean verboseLabels) {
		getStore().setValue(VERBOSE_LABELS, verboseLabels);
	}

	private static IPreferenceStore getStore() {
		if (store==null) {
			store = ArneUIPlugin.getInstance().getPreferenceStore();
		}
		return store;
	}
	
}
